(function (doc, win) {
    const DESIGN_WIDTH = 750;
    const MAX_FONT_SIZE = 100;

    const docEl = doc.documentElement;
    const resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';

    function recalc() {
        let clientWidth = docEl.clientWidth;

        // PC 端内容居中，最大宽度为 667px
        if (clientWidth > 667) {
            clientWidth = 667;
        }

        let fontSize = Math.min(MAX_FONT_SIZE, (clientWidth / DESIGN_WIDTH) * 100);
        docEl.style.fontSize = `${fontSize}px`;
    }

    if (!doc.addEventListener) return;
    win.addEventListener(resizeEvt, recalc, false);
    doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);